#include <iostream>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <deque>

using namespace std;

typedef long long int64;
typedef unsigned int ui;

int wall[100][100];
int visit[10][10];
int _right[10][10];
int down[10][10];

int x[100];
int y[100];

int n, m, nn;

int validCount;
int passed;

void DFS(int i, int j)
{
	if (visit[i][j]) return ;
	if (wall[i][j] > 0) ++passed;
	
	visit[i][j] = true;
	if (i == 0)
	{
		if (passed != m) return;
		int op = 0, cl = 1;
		static int a[100], b[100];
		static int mark[10][10];
		memset(mark, 0, sizeof(mark));
		a[0] = b[0] = 0;
		mark[0][0] = 1;
		
		while (op < cl)
		{
			int u = a[op], v = b[op];
			++op;
			if (v < nn - 1 && !mark[u][v + 1] && !down[u][v + 1])
			{
				a[cl] = u;
				b[cl] = v + 1;
				mark[u][v + 1] = true;
				++cl;
			}
			if (v > 0 && !mark[u][v - 1] && !down[u][v - 1])
			{
				a[cl] = u;
				b[cl] = v - 1;
				mark[u][v - 1] = true;
				++cl;
			}
			if (u < nn - 1 && !mark[u + 1][v] && !_right[u + 1][v])
			{
				a[cl] = u + 1;
				b[cl] = v;
				mark[u + 1][v] = true;
				++cl;
			}
			if (u > 0 && !mark[u - 1][v] && !_right[u][v])
			{
				a[cl] = u - 1;
				b[cl] = v;
				mark[u - 1][v] = true;
				++cl;
			}
			if (cl == 2 * n * n)
				++ validCount;
		}
		return;
	}
	
	if (i < nn - 1)
	{
		if (j != 0 && j != nn)
		{
			down[i][j] = 1; DFS(i + 1, j); down[i][j] = 0;
		}
	}
	if (i > 0)
	{
		if (j != 0 && j != nn)
		{
			down[i - 1][j] = 1; DFS(i - 1, j); down[i][j] = 0;
		}
	}
	if (j < nn - 1)
	{
		if (i != 0 && i != nn)
		{
			_right[i][j] = 1; DFS(i, j + 1); _right[i][j] = 0;
		}
	}
	if (j > 0)
	{
		if (i != 0 && i != nn)
		{
			_right[i][j - 1] = 1; DFS(i, j - 1); _right[i][j - 1] = 0;
		}
	}
}

int main()
{
	cin >> n >> m;
	nn = n * 2;
	
	memset(_right, 0, sizeof(_right));
	memset(down, 0, sizeof(down));

	for (int i = 0; i < m; ++i)
	{
	    cin >> x[i] >> y[i];
	    wall[x[i]][y[i]] = 1;
	}
	validCount = 0;
	passed = 0;
	for (int i = 1; i < 2 * n; ++i)
	    DFS(i, 0);
	cout << validCount << endl;
	getc(stdin);
	getc(stdin);
	return 0;
}
